﻿//png24 nav
if (!!window.DD_belatedPNG) {
    DD_belatedPNG.fix(".slide-triggers");
};

$(document).ready(function () {
    //通知滚动
    setInterval("slide($('#J_notice'),18,500)", 5000);

    //左下角广告
    var J_slidesub = $("#J_slidesub");
    var J_slidesub_list = J_slidesub.find(".slide-list li");
    var J_slidesub_trigger_html = "<ul class=\"slide-triggers\" >";
    for (var i = 0; i < J_slidesub_list.length; i++) {
        j = i + 1;
        J_slidesub_trigger_html += "<li>" + j + "</li>";
    };
    J_slidesub_trigger_html += "</ul>";
    J_slidesub.append(J_slidesub_trigger_html);
    setInterval("slide($('#J_slidesub'),88,500)", 5000);
    J_slidesub.find(".slide-triggers li").mouseover(function (event) {
        event.stopPropagation();
        var eq = $.inArray(this, $.makeArray(J_slidesub.find(".slide-triggers li")));
        var count = J_slidesub_list.length;
        J_slidesub.attr("data-eq", eq).find(".slide-list").animate({ top: -eq * 88 }, 500);
        $(this).parent().find("li").removeClass("slide-current").eq(eq).addClass("slide-current");
    }).eq(0).mouseover();

});

//轮播
function slide(element, step, time) {
    var slide_list = element.find(".slide-list");
    var slide_triggers = element.find(".slide-triggers");
    var count = slide_list.children().length;
    if (count < 2) { return; }
    var slide_list_first = slide_list.children().eq(0);
    var eq = parseInt(element.attr("data-eq"));
    if (isNaN(eq)) { eq = -1; element.attr("data-eq", "0"); };
    eq += 1;
    if (eq > count - 1) {
        slide_list_first.css({ "position": "relative", "top": (count * step) + "px" });
        eq = 0;
        slide_list.animate({ top: -count * step }, time, function () {
            slide_list.animate({ top: 0 }, 0);
            slide_list_first.removeAttr("style");
        });
    } else {
        slide_list.animate({ top: -eq * step }, time);
    }
    element.attr("data-eq", eq);
    slide_triggers.children().removeClass("slide-current").eq(eq).addClass("slide-current");
};